package com.ruoyi.ms.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ms.domain.MsOrderIncome;
import com.ruoyi.ms.service.IMsOrderIncomeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 妙手虾皮订单收入明细Controller
 * 
 * @author chdx
 * @date 2022-12-06
 */
@Controller
@RequestMapping("/ms/MsOrderIncome")
public class MsOrderIncomeController extends BaseController
{
    private String prefix = "ms/MsOrderIncome";

    @Autowired
    private IMsOrderIncomeService msOrderIncomeService;

    @RequiresPermissions("ms:MsOrderIncome:view")
    @GetMapping()
    public String MsOrderIncome()
    {
        return prefix + "/MsOrderIncome";
    }

    /**
     * 查询妙手虾皮订单收入明细列表
     */
    @RequiresPermissions("ms:MsOrderIncome:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MsOrderIncome msOrderIncome)
    {
        startPage();
        List<MsOrderIncome> list = msOrderIncomeService.selectMsOrderIncomeList(msOrderIncome);
        return getDataTable(list);
    }

    /**
     * 导出妙手虾皮订单收入明细列表
     */
    @RequiresPermissions("ms:MsOrderIncome:export")
    @Log(title = "妙手虾皮订单收入明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MsOrderIncome msOrderIncome)
    {
        List<MsOrderIncome> list = msOrderIncomeService.selectMsOrderIncomeList(msOrderIncome);
        ExcelUtil<MsOrderIncome> util = new ExcelUtil<MsOrderIncome>(MsOrderIncome.class);
        return util.exportExcel(list, "妙手虾皮订单收入明细数据");
    }

    /**
     * 新增妙手虾皮订单收入明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存妙手虾皮订单收入明细
     */
    @RequiresPermissions("ms:MsOrderIncome:add")
    @Log(title = "妙手虾皮订单收入明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MsOrderIncome msOrderIncome)
    {
        return toAjax(msOrderIncomeService.insertMsOrderIncome(msOrderIncome));
    }

    /**
     * 修改妙手虾皮订单收入明细
     */
    @RequiresPermissions("ms:MsOrderIncome:edit")
    @GetMapping("/edit/{orderIncomeId}")
    public String edit(@PathVariable("orderIncomeId") Long orderIncomeId, ModelMap mmap)
    {
        MsOrderIncome msOrderIncome = msOrderIncomeService.selectMsOrderIncomeByOrderIncomeId(orderIncomeId);
        mmap.put("msOrderIncome", msOrderIncome);
        return prefix + "/edit";
    }

    /**
     * 修改保存妙手虾皮订单收入明细
     */
    @RequiresPermissions("ms:MsOrderIncome:edit")
    @Log(title = "妙手虾皮订单收入明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MsOrderIncome msOrderIncome)
    {
        return toAjax(msOrderIncomeService.updateMsOrderIncome(msOrderIncome));
    }

    /**
     * 删除妙手虾皮订单收入明细
     */
    @RequiresPermissions("ms:MsOrderIncome:remove")
    @Log(title = "妙手虾皮订单收入明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(msOrderIncomeService.deleteMsOrderIncomeByOrderIncomeIds(ids));
    }
}
